/**
 * Created by Administrator on 2017/4/1.
 */
"use strict";
swan_pc
    .controller("PersonalOppRelevantController",function($scope,$rootScope,$state,oppPartner,oppRelevant) {

        $scope.getRelevant = function () {
            oppRelevant.query({id: $rootScope.opp.id}, function (result) {
                $scope.relevant = result;
                console.log('Relevant:', $scope.relevant);
            })
        };
        $scope.getRelevant();

        $scope.setList=function () {
            $scope.benefitList=[
                {
                    name:'有利',
                    value:1
                },
                {
                    name:'部分',
                    value:2
                },
                {
                    name:'不利',
                    value:3
                }
            ];
            $scope.zixunList=[
                {
                    name:'主要咨询人',
                    value:1
                },
                {
                    name:'业务人员',
                    value:2
                },
                {
                    name:'支持人员',
                    value:3
                },
                {
                    name:'联系人',
                    value:4
                },
                {
                    name:'其他',
                    value:5
                }
            ];
            $scope.zhaobiaoList=[
                {
                    name:'联系人',
                    value:1
                },
                {
                    name:'项目负责人',
                    value:2
                }
            ];
            $scope.seniorList=[
                {
                    name:'资深',
                    value:1
                },
                {
                    name:'相对资深',
                    value:2
                },
                {
                    name:'嫩',
                    value:3
                },
                {
                    name:'我不清楚',
                    value:4
                },
            ];
            $scope.reliableList=[
                {
                    name:'可靠',
                    value:1
                },
                {
                    name:'相对可靠',
                    value:2
                },
                {
                    name:'油滑',
                    value:3
                },
                {
                    name:'我不清楚',
                    value:4
                },
            ];
        };
        $scope.setList();

        $scope.setStruct=function () {
            $scope.relevantStruct=[
                {
                    blockName: '相关人员',
                    blockKey: 'relevantContacts',
                    type: 'repeatOnly',
                    list: [],
                    struct: [
                        {
                            name:'姓名',
                            key:'userContact',
                            type: 4,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow:1,
                        },
                        {
                            name:'此人身份',
                            key:'role',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.selectedRelevant.type?$scope.zixunList:$scope.zhaobiaoList,
                            numInRow:2,
                        },
                        {
                            name:'此人资深程度',
                            key:'senior',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.seniorList,
                            numInRow:2,
                        },
                        {
                            name:'此人可靠程度',
                            key:'reliable',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.reliableList,
                            numInRow:2,
                        },
                        {
                            name:'此人能得到信息',
                            key:'direct',
                            type: 5,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow:2,
                        }
                    ]
                },
                {
                    blockName: '有关公司资质要求',
                    blockKey: 'qualifications',
                    type: 'repeatOnly',
                    list: [],
                    struct: [
                        {
                            name:'具体要求',
                            key:'name',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name:'是否有利于我们',
                            key:'benefit',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'',
                            key:'',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                    ]
                }
            ]
        }

        $scope.selectRelevant=function (relevant) {
            $scope.show=true;
            $scope.selectedRelevant=relevant;
            $scope.relevantPoint={
                qualifications:relevant.qualifications,
                relevantContacts:relevant.relevantContacts
            };
            $scope.setStruct();
        }

    })